
In this part we will discuss JavaScript JSON. JSON full form is JavaScript Object Notation. JSON is an Object type. This Object type very popular in JavaScript. Basically, we pass the json data and receive the json data from our programming. When we develop the real time application then we work with JSON. JSON is very popular object. JSON is a lightweight data interchange format. JSON is language independent JSON is "self-describing" and easy to understand. Now given bellow the example code and explain the code:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript">
//object JSON
var human = '{"employees":[' +
'{"firstName":"Farhan","lastName":"Sakib" },' +
'{"firstName":"Reza","lastName":"Karim" },' +
'{"firstName":"Tofile","lastName":"Ahmad" }]}';
obj = JSON.parse(human);
console.log(obj.employees[1].firstName + " " + obj.employees[1].lastName);
</script>
</body>
</html>
In this code we create the JSON object name as ‘employees’ then full object assigns into human variables. This ‘employees’ JSON data contain the three human details. Then we convert data using ‘JSON.parse’ function and print the one human first name and last name property using the ‘console.log’ method.